Bug Killer
A colored way to find bugs and fix them.
Example
var Debug = require("../index");
Debug.config.logLevel = 4;
Debug
.log("A fancy error message", "error")
.log("Info messages are useful", "info")
.log("Hey, you've got a warning", "warn")
;
Debug.config.displayDate = false;
Debug.log("Display date is disabled.", "info");
Debug.config.myType = {
color: [0, 255, 200]
, text: "custom"
};
Debug.log("This is a custom message type", "myType");
Documentation
Methods
getDate()
Returns the stringified date. This method can be overrided for a custom date format.
Return
- String The date in HH:mm.ss - DD.MM.YYYY format.
log(message, type)
Displays debug messages by providing the type.
Params
- String
message
: The debug message that should be displayed
- String
type
: The message type (e.g. "error", "info" etc)
Return
- Object BugKiller instance
Other fields
config
An object contaning the configuration of the module.
Default:
BugKiller.config = {
error: {
color: [192, 57, 43]
, text: "error"
, level: 1
}
, warn: {
color: [241, 196, 15]
, text: "warn "
, level: 2
}
, info: {
color: [52, 152, 219]
, text: "info "
, level: 3
}
, displayDate: true
, logLevel: 2
};
It can be extended to accept any type of message (see example).
How to contribute
- File an issue in the repository, using the bug tracker, describing the
contribution you'd like to make. This will help us to get you started on the
right foot.
- Fork the project in your account and create a new branch:
your-great-feature
.
- Commit your changes in that branch.
- Open a pull request, and reference the initial issue in the pull request
message.
Changelog
1.0.0
- Removed almost useless if statement that was checking if
type
is valid. The programmer is responsible for that and should use existing message types.
- Updated
couleurs
dependency.
- Lowercase message types.
_config
becomes config
getDate
handler. Fixes #3.
- Use
process.stdout.isTTY
to handle redirected output. Fixes #2.
v0.1.1
v0.1.0
License
See the LICENSE file.